<template>
  <div class="open-source-box">
    <!-- 编辑状态 -->
    <div class="open-source-item" v-if="true">
      <div class="style-item">
        <div class="point" v-if="shape === 'point'" :style="{ backgroundColor: myThemeColor }"></div>
        <div class="square" v-if="shape === 'square'" :style="{ backgroundColor: myThemeColor }"></div>
      </div>
      <div style="flex-grow: 1; padding: 5px 15px">
        <!-- <el-input
          type="textarea"
          class="myinput"
          placeholder="请输入内容"
          @change="onChange"
          v-model="content"
          :style="comStyle"
          :autosize="{ minRows: 1, maxRows: 5 }"
        ></el-input>-->
        <div
          class="myinput"
          :style="comStyle"
          contenteditable="true"
          @focusout="onChange"
          ref="contentRef"
        >{{content}}</div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      content: ""
    };
  },
  props: {
    data: {
      type: String,
      required: true,
      default:
        "负责相关产品的需求以及前端程序的实现，提供合理的前端架构。改进和优化开发工具、开发流程、和开发框架"
    },
    edit: {
      type: Boolean,
      default: true
    },
    dataIndex: {
      type: Number,
      default: 0
    },
    shape: { type: String, default: "" },
    backgroundColor: {
      type: String,
      default: "white"
    }
  },
  computed: {
    comStyle() {
      return this.backgroundColor !== "white"
        ? {
            color: "#fff",
            fontSize: this.myFontSize,
            lineHeight:1.5
          }
        : {
            fontSize: this.myFontSize,
            lineHeight:1.5
          };
    },
    ...mapGetters(["myFontSize", "myThemeColor"])
  },
  methods: {
    // 文本内容改变，
    onChange() {
      if (this.$refs.contentRef.innerHTML !== this.content) {
        this.$emit("textChange", this.$refs.contentRef.innerHTML);
      }
    }
  },
  created() {
    this.content = this.data;
  }
};
</script>

<style lang="less" scoped>
.open-source-box {
  padding: 0;
  width: 100%;
}
.style-item {
  padding-top: 15px;
}

.point {
  box-sizing: border-box;
  width: 10px;
  height: 10px;
  border-radius: 5px;
  padding: 5px;
}
.square {
  box-sizing: border-box;
  width: 10px;
  height: 10px;
  padding: 5px;
}
.open-source-item {
  display: flex;
  color: black;
  align-items: center;
  position: relative;
  align-items: flex-start;
}
.myinput {
  border: none;
  padding: 1px;
  background-color: transparent;
  resize: none;
  border: none;
  -webkit-user-modify: read-write-plaintext-only;
}
.myinput:focus {
  border: 0px;
  border-color: tomato;
  border-width: 1px;
  border-style: dotted;
}

/deep/ .el-textarea__inner {
  resize: none;
  border: none;
  font-size: inherit;
  padding: 5px 0;
  background-color: transparent;
  color: inherit;
}

/deep/ .el-textarea__inner:focus {
  border: 0px;
  border-color: tomato;
  border-width: 1px;
  border-style: dotted;
}

.text {
  position: absolute;
  display: none;
}

.input-text {
  padding: 15px 20px;
  flex-grow: 1;
  text-align: left;
  white-space: pre-wrap;
}
</style>
